package com.youhome.business.controller;

import com.youhome.common.exception.CustomException;
import com.youhome.common.response.Result;
import com.youhome.common.response.ResultCode;
import com.youhome.service.service.BShareGroupService;
import com.youhome.service.service.BShareService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Created by chen365 on 2017/11/2.
 */
@RestController
@RequestMapping(value = "/share")
@Api(tags = "分享")
public class ShareController {

    @Autowired
    private BShareService bShareService;

    @ApiOperation(value = "浏览分享", notes = "查看房源分享组，生成下一级分享地址")
    @ApiImplicitParams({
            @ApiImplicitParam(dataType = "String", name = "shareId", value = "分享组ID", required = true, paramType = "query"),
            @ApiImplicitParam(dataType = "int", name = "level", value = "分享级别", required = true, paramType = "query")
    })
    @GetMapping(value = "/browse")
    public Object browse(HttpServletRequest request, HttpServletResponse response,String shareId, Integer level) throws CustomException {
        return new Result(ResultCode.SUCCESS, bShareService.browse(request, response, shareId, level));
    }

}
